package com.ruoyi.library.controller;

import javax.annotation.Resource;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.library.api.query.DigitalTwinComponentQuery;
import com.ruoyi.library.api.vo.DigitalTwinComponentVO;
import com.ruoyi.library.domain.DtsDigitalTwinComponent;
import com.ruoyi.library.service.IDtsDigitalTwinComponentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.core.web.controller.BaseController;

/**
 * 构件
 *
 * @author ZhangYu
 * @date 2024-05-16
 */
@Api(tags = "构件")
@RestController
@RequestMapping("/component")
public class DtsDigitalTwinComponentController extends BaseController {

    @Resource
    private IDtsDigitalTwinComponentService digitalTwinComponentService;

    /**
     * 构件信息分页
     *
     * @param digitalTwinComponentQuery 构件信息查询条件
     * @return 构件信息分页
     */
    @ApiOperation("构件信息分页")
    @GetMapping("/page")
    public R<Page<DigitalTwinComponentVO>> componentInfoPage(DigitalTwinComponentQuery digitalTwinComponentQuery) {
        Page<DigitalTwinComponentVO> componentInfoPage = digitalTwinComponentService.componentInfoPage(digitalTwinComponentQuery);
        return R.ok(componentInfoPage);
    }

    /**
     * 构件详情
     *
     * @param id 唯一主键
     * @return 构件详情
     */
    @ApiOperation("构件详情")
    @GetMapping("/info")
    public R<DigitalTwinComponentVO> getComponentInfoById(@RequestParam Long id) {
        DtsDigitalTwinComponent digitalTwinComponent = digitalTwinComponentService.getById(id);
        return R.ok(BeanUtil.copyProperties(digitalTwinComponent, DigitalTwinComponentVO.class));
    }

}
